package com.project.controller;

import com.project.bean.RoomSetBean;
import com.project.service.IRoomSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("roomSet")
public class RoomSetController {
    @Autowired
    private IRoomSetService roomSetService;

    /**
     * 通过房间id查询房间中设施损坏的记录
     *
     * @param id 房间id
     * @return 设施损坏记录集合
     * @return 设施损坏记录集合
     */
    @RequestMapping("findById")
    public List<RoomSetBean> findById(int id) {
        return roomSetService.findByRoom(id);
    }

    /**
     * 添加设施记录
     *
     * @param info   设施记录信息
     * @param roomId 房间id
     */
    @RequestMapping("add")
    public void add(String info, int roomId) {
        RoomSetBean roomSetBean = new RoomSetBean(info, roomId);
        roomSetService.add(roomSetBean);
    }

    /**
     * 修改设施损坏记录
     *
     * @param roomId    房间id
     * @param roomSetId 房间设施id
     */
    @RequestMapping("update")
    public void updateSet(int roomId, int roomSetId) {
        roomSetService.pressRoomSet(roomId, roomSetId);
    }
}
